import request from '@/utils/request'
import {saveAs} from 'file-saver'

// 查询自动报告列表
export function listAutoReportLog(query) {
    return request({
        url: '/admin-api/autoreport/report-log/page',
        method: 'get',
        params: query
    })
}

// 查询全部自动报告列表
export function listAllAutoReportLog(query) {
    return request({
        url: '/admin-api/autoreport/report-log/getAll',
        method: 'get',
        params: query
    })
}

// 查询自动报告详细
export function getAutoReportLog(query) {
    return request({
        url: '/admin-api/autoreport/report-log/get',
        method: 'get',
        params: query
    })
}

// 新增自动报告
export function addAutoReportLog(data) {
    return request({
        url: '/admin-api/autoreport/report-log/create',
        method: 'post',
        data: data
    })
}

// 修改自动报告
export function updateAutoReportLog(data) {
    return request({
        url: '/admin-api/autoreport/report-log/update',
        method: 'put',
        data: data
    })
}

// 配置自动报告
export function configureAutoReportLog(data) {
    return request({
        url: '/admin-api/autoreport/report-log/configure',
        method: 'put',
        data: data
    })
}

// 修改自动报告状态
export function updateAutoReportLogStatus(data) {
    return request({
        url: '/admin-api/autoreport/report-log/update-status',
        method: 'put',
        params: data
    })
}

// 删除自动报告
export function delAutoReportLog(data) {
    return request({
        url: '/admin-api/autoreport/report-log/delete',
        method: 'delete',
        params: data
    })
}

// 批量删除自动报告
export function delAutoReportLogList(data) {
    return request({
        url: '/admin-api/autoreport/report-log/delete-list',
        method: 'delete',
        params: data
    })
}

// 下载文件
export function exportAutoReportLog(data) {
    return request({
        url: '/admin-api/autoreport/report-log/export-excel',
        method: 'get',
        params: data,
        responseType: 'blob',
    }).then(res => {
        const blob = new Blob([res], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"})
        saveAs(blob, decodeURIComponent('主机记录.xlsx'))
    })
}